[contents] [prev] [next] [top] [bottom] (4 out of 5)

Finding Information About Classes and Objects

This section describes generic functions that are useful for finding information about a class or object, such as what its superclasses are, whether it defines a particular generic function, or the class of a given object. These methods are defined by the classes RootObject, RootClass, and Behavior, and as such, they are available to all classes and objects. For more information, see the "Object System Kernel" chapter of the ScriptX Components Guide, and the definitions of RootObject and Behavior in the ScriptX Class Reference.

RootObject, Behavior, and RootClass define several generic functions that expose API that is private, and not considered part of the ScriptX Language and Class Library. Any classes, objects, instance variables, or methods not documented in the Kaleida Technical Reference Series, or in associated release notes, are not supported by Kaleida. Since such API is likely to change with future versions of ScriptX, using it in a title or tool may result in future incompatibilities with Kaleida products. Some of the generic functions discussed here return a very large collection of objects, generally in an array. By default, only the first ten elements of a collection are printed to a stream. You might want to read ahead to section "Output" which begins on page 72 to explore options for printing a complete listing.

getSubs class
getSupers class
The getSubs and getSupers generic functions return an array of all the subclasses or superclasses of class, respectively. For getSupers, this includes all the classes up to RootObject. The generic function getSupers returns an array in exact inheritance precedence order.

getDirectSubs class
getDirectSupers class
In contrast with getSubs and getSupers, the generics getDirectSubs and getDirectSupers return an array of immediate (direct) subclasses or superclasses of class, respectively.

isDirectSub class otherClass
isSub class otherClass
isMemberOf class object
The generic functions isDirectSub, isSub, and isMemberOf test the relationship between two classes, or between a class and an object. The isDirectSub generic returns true if class is a direct subclass of the class otherClass; the isSub generic returns true if class inherits from the class otherClass. The isMemberOf generic returns true if the given object is an instance of class.

allInstances class
The generic function allInstances returns an Array object containing a list of all instances of class that currently exist in the system. Note that instances of a subclass are considered instances of the given class.

getClassName object
getClass object
The getClassName function returns a string containing the name of the class, of which object is an instance. The getClass function returns the class object of which the object is an instance. Comparisons using getClass are more efficient than they would be with getClassName, since getClassName requires the system to create and compare strings. The getClass generic function references the object's own class object directly.

isAKindOf object class
The isAKindOf generic function tests the relationship between object and class. If object is an instance of the given class, or if object is an instance of a class that inherits from this class, isAKindOf returns true.

getDirectGenerics object
getAllGenerics object
The getDirectGenerics function returns an array containing all the generic functions that are implemented by methods that are defined directly by the class that object is an instance of. The getAllGenerics function returns all the generic functions available to object, whether they are implemented in the class itself or in any of its superclasses.

canObjectDo object  generic
The canObjectDo function tests whether object has an implementation (a method) for the generic function generic. This generic functions is often called on class objects.

ivNames classOrObject
allIvNames classOrObject
The ivNames function returns a sorted array of instance variables defined only on the class or object. The allIvNames function returns a sorted array of all instance variables available to the class or object, including instance variables inherited from all the superclasses of this class. Both these functions return only those instance variables that occupy real places in memory, which may not be all the available instance variables. For a complete list, use getDirectGenerics or getAllGenerics, and locate those generic functions that end with -Getter.


This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.

Copyright 1996 Apple Computer, Inc. All Rights Reserved.